package cn.threewaters.qtyy.tools.autocode;

import cn.threewaters.qtyy.tools.autocode.ui.MainFrame;
import cn.threewaters.qtyy.tools.autocode.util.FrameTool;

import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.util.Enumeration;

public class Main {
	public static void main(String[] args) {
		try {
			resetStyle();
			MainFrame login = new MainFrame();
			login.setResizable(false);
			login.setSize(500, 500);
			FrameTool.setCenter(login);
			login.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE);
			login.setTitle("Genetor v1.0");
			login.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void resetStyle() throws Exception {
		BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.osLookAndFeelDecorated;
		org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
		UIManager.put("RootPane.setupButtonVisible", false);
		initGlobalFontSetting(new Font("微软雅黑", Font.PLAIN, 14));
	}

	public static void initGlobalFontSetting(Font fnt) {
		FontUIResource fontRes = new FontUIResource(fnt);
		for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
			Object key = keys.nextElement();
			Object value = UIManager.get(key);
			if (value instanceof FontUIResource)
				UIManager.put(key, fontRes);
		}
	}
}
